package hibernate_basic.Persistence.delete_data;

import hibernate_basic.Persistence.comment_persitence.Person;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

/**
 * @author Administrator
 * @create 2018-12-31 10:07
 * @desc 删除数据
 **/
public class DeleteData {

    public static void main(String args[]){

        Configuration config=new Configuration();
        config.configure("hibernate_basic/config/config_comment/hibernate.cfg.xml");

        SessionFactory sefac=config.buildSessionFactory();
        Session session=sefac.openSession();
        Transaction tran=session.beginTransaction();
        Person person=(Person)session.get(Person.class,13);
        session.delete(person);
        //session.flush();
        tran.commit();
        session.close();
    }






}
